﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Projekt
{
    public partial class deleteOldNir : Form
    {
        Dalgen conn = Dalgen.Instance;
        public deleteOldNir()
        {
            InitializeComponent();
        }

        private void year_Validating()
        {
            delete.Enabled = true;
            try
            {
                Convert.ToInt64(yearInputBox.Text);
            }
            catch (Exception es) { delete.Enabled = false; }
        }

        private void month_Validating()
        {
            delete.Enabled = true;
            try
            {
                int honap = Convert.ToInt32(monthInputBox.Text);
                if (honap > 12 || honap <= 0) delete.Enabled = false; 
            }
            catch (Exception es) { delete.Enabled = false; }
        }

        private void day_Validating()
        {
            delete.Enabled = true;
            try
            {
                int nap = Convert.ToInt32(dayInputBox.Text);
                if (nap > 31 || nap <= 0) delete.Enabled = false;
            }
            catch (Exception es) { delete.Enabled = false; }
        }
    
        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void yearInputBox_TextChanged(object sender, EventArgs e)
        {
            year_Validating();
        }

        private void monthInputBox_TextChanged(object sender, EventArgs e)
        {
            month_Validating();
        }

        private void dayInputBox_TextChanged(object sender, EventArgs e)
        {
            day_Validating();
        }

        private void delete_Click(object sender, EventArgs e)
        {
            conn.deleteOldNir(yearInputBox.Text, monthInputBox.Text, dayInputBox.Text);
            this.Close();
        }
    }
}
